package com.builder;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

import org.mvn_spring_jsf_jar.model.Cliente;
import org.mvn_spring_jsf_jar.model.PagoServicio;

import com.view.PagoServicioView;

@SuppressWarnings("serial")
@ManagedBean
@ViewScoped
public class PagoServicioBuilder implements
		BaseBuilder<PagoServicioView, PagoServicio>, Serializable {

	@ManagedProperty("#{clienteBuilder}")
	private ClienteBuilder clienteBuilder;

	public PagoServicio toDomain(PagoServicioView view) {
		Cliente cliente = null;
		if (view.getClienteView() != null) {
			cliente = clienteBuilder.toDomain(view.getClienteView());
		}
		return new PagoServicio(view.getId(), view.getMonto(), view.getFecha(),
				cliente, view.getComentario());
	}

	public PagoServicioView toView(PagoServicio model) {
		return new PagoServicioView(model.getID(), model.getMonto(),
				model.getFecha(), clienteBuilder.toView(model.getCliente()),
				model.getComentario());
	}

	public ClienteBuilder getClienteBuilder() {
		return clienteBuilder;
	}

	public void setClienteBuilder(ClienteBuilder clienteBuilder) {
		this.clienteBuilder = clienteBuilder;
	}
}
